package so.sao.code.service.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import so.sao.code.service.domain.entity.EnterpriseDomain;

import java.lang.annotation.Native;
import java.util.List;

@Repository
public interface EnterpriseDomainDao extends JpaRepository<EnterpriseDomain, Long> {
    @Query(value = "select convert(varchar(255),qrcode_domain.domain_url) as domain_url FROM qrcode_domain,enterprise_domain where qrcode_domain.id=enterprise_domain.domain_id and ese_id = ?1", nativeQuery = true)
    List<String> findByEseId(Long eseId);

    void deleteByDomainIdAndEseId(Long domainId, Long eseId);
    @Query(value = "SELECT  *  FROM  enterprise_domain where ese_id= ?1 and sub_domain!=''", nativeQuery = true)
    EnterpriseDomain findSubByEseId(long eseId);
}
